package com.ruoyi.common.enums;

/**
 * 风控类型
 * @author zhoudong
 */
public enum RiskTypeEnum {
    /**
     * 大于等于83
     */
    RADICAL(0,"RADICAL","激进型"),
    /**
     * 大于等于54，小于等于82
     */
    POSITIVE(1,"POSITIVE","积极型"),
    /**
     * 大于等于37，小于等于53
     */
    STEADY(2,"STEADY","稳健型"),
    /**
     * 大于等于20，小于等于36
     */
    CAUTIOUS(3,"CAUTIOUS","谨慎型"),
    /**
     * 大于等于0，小于20
     */
    CONSERVATIVE(4,"CONSERVATIVE","保守型");

    private final int code;
    private final String insCode;
    private final String message;

    RiskTypeEnum(int code, String insCode, String message) {
        this.code = code;
        this.insCode = insCode;
        this.message = message;
    }

    /**
     * 通过代码获取枚举项
     * @param code
     * @return
     */
    public static RiskTypeEnum getByCode(int code) {
        if (code == -1) {
            return null;
        }

        for (RiskTypeEnum le : RiskTypeEnum.values()) {
            if (le.getCode() == code) {
                return le;
            }
        }

        return null;
    }
    /**
     * 通过描述获取枚举项
     * @param message
     * @return
     */
    public static RiskTypeEnum getByMessage(String message) {
        if (message == null) {
            return null;
        }

        for (RiskTypeEnum le : RiskTypeEnum.values()) {
            if (le.getMessage().equals(message)) {
                return le;
            }
        }

        return null;
    }

    /**
     * 通过代码获取枚举项
     * @param insCode
     * @return
     */
    public static RiskTypeEnum getByInsCode(String insCode) {
        if (insCode == null) {
            return null;
        }

        for (RiskTypeEnum le : RiskTypeEnum.values()) {
            if (le.getInsCode().equals(insCode)) {
                return le;
            }
        }

        return null;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getInsCode() {
        return insCode;
    }
}
